home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c
- Subject: Re: Fastest way to computer log(base2) of x?
- Date: 7 Feb 1996 20:38:36 GMT
- Organization: Borland International
- Message-ID: <4fb2kc$i8n@druid.borland.com>
- References: <4e61iu$p6e@villa.fc.net> <4e72il$dvl@ns.RezoNet.NET> <4f647p$lc5@druid.borland.com> <9602061633.AA15316@dxmint.cern.ch>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <9602061633.AA15316@dxmint.cern.ch>, danpop@mail.cern.ch says...
- >
- >pete@borland.com (Pete Becker) writes:
- >
- >>Still faster: use a table with INT_MAX entries and remove all of the
- >>conditionals. Why do the responses here assume that sacrificing speed for
- >>space savings is appropriate? The question asks for the fastest, not
- something
- >>that's reasonably fast but doesn't use much space.
- >
- >Initializing a table with 2147483648 entries might take quite a lot of
- >time. That is, assuming that the system is configured with enough virtual
- >memory :-)
-
- Yes, but that's a one-time cost, and amortized over many lookups it becomes
- vanishingly small. So the limiting case is that the cost of making this
- determination is a single memory access. That is, assuming that the system is
- configured with enough real memory. <g>
-
-